<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=8">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta content="B2B电商平台" name="description" />
		<meta content="B2B电商平台" name="keyword" />

		<title>B2B电商平台.店铺商品类型维护</title>
		<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="include/images/icss.ico"
			type="image/x-icon" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/include/css/global.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/include/css/style.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/include/css/pro.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/include/css/proManage.css" />
		<link rel="stylesheet"
			href="<%=path%>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css"
			type="text/css"></link>
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />	
		<script type="text/javascript"
			src="<%=path%>/include/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/cookies.js"></script>
		<script type="text/javascript"
			src="<%=path%>/include/js/icss.busin.js"></script>
		<script type="text/javascript"
			src="<%=path%>/include/JQuery ui/js/jquery-ui-1.7.3.custom.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/include/js/icss.common.js"></script>
		<script src="<%=path%>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>
		<style type="text/css">

.trBgd {
	background: url("<%=path%>/images/coupons/sort_zss.png");
}
.tag_x button{
	background-image: url("<%=path%>/include/css/img/xs_bgx.png");
    background-color: transparent;
}
a{
	text-decoration:none;out-line: none;
}
a:HOVER{
	color: #fff;
}
.tdL{
	width: 210px;;text-align: right;padding-right: 5px;
}
.tdR{
	text-align: left;padding-left: 5px;
}
.tdR input{
	height: 24px;width: 180px;
}
.subDiv{
	height: 31px;line-height: 31px;background: #e51400;border-radius: 3px;width: 60px;margin-top: 10px;margin-left: 5px;float: left;
}
.subA{
	color: #fff;
}
.backDiv{
	height: 31px;line-height: 31px;background: #999;border-radius: 3px;width: 60px;margin-top: 10px;margin-left: 5px;float: left;
}
button{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
</style>
		<script type="text/javascript">
	$(function(){
		var id = '${info.rdeId }';
		if(null==id || ""==id) $("#title").text("新增");
		else {
			if("info"=="${flag}"){
				$("#info").css("display","");
				$("#title").css("display","none");
			}else $("#title").text("编辑");
		}
		if("info"=="${flag}"){
			 $("#btnDiv").css("display","none");
			 $(".Wdate").removeClass("Wdate");
			 $("input").removeAttr("onclick");
			 $("input").attr("readonly","readonly");
			 $("select").attr("disabled","disabled");
		}
	});
	function _verifyNum(id){
		var val = $("#"+id).val();
		var reg = /^[1-9][0-9]*$/;
		if(!reg.test(val)){
			$("#"+id).val("");
			$(".reg"+id).css("display","");
		}else{
			$(".reg"+id).css("display","none");
		}
	}
	var num = 0;
	function _save(){
		_getVal();
		if(dataN!=0) $("#dialogDiv").dialog("open");
		else _subInfo();
	}

	function _subInfo(){
		if(num==0){
			$(".subDiv").css("background","#c7c7c7");
			$(".subA").css("color","#000");
		}else{
			return;
		}
		num = 1;
		var rdeId = $("#rdeId").val();
		var url = "<%=path%>/fullReduce/save.do";
		if(rdeId!="") url = "<%=path%>/fullReduce/updateInfo.do";
		$.ajax({
			type:"post",
			url:url,
			dataType:"json",
			data:dataNum,
			success:function(data){
				if(data){
					var flag = data.flag;
					if(flag=="1")
						window.location.href = "<%=path%>/fullReduce/toFullReduceListPage.do";
					else{
						$(".subDiv").css("background","#e51400");
						$(".subA").css("color","#fff");
						num = 0;
					}
				}
			}
		});
	}

	var dataN = 0;
		var dataNum = {};
	function _getVal(){
		var ids = "rdeId,rdeName,cpsPrice,begDate,endDate,useCtn,status";
		var arr = ids.split(",");
		for(var i=0;i<arr.length;i++){
			var id = arr[i];
			var val = $("#"+id).val();
			if(id!="rdeId") _verifyNull(id);
			dataNum[id]=val;
		}
	}

	function _verifyNull(id){ //验证数据是否为空
		var val = $("#"+id).val();
		if(""==val){
			$("."+id).css("display",""); 
			dataN ++;
		}
	}

	$(document).ready(function() {
		$("#dialogDiv").dialog({
			autoOpen : false,   // 是否自动弹出窗口
			modal : true,    // 设置为模态对话框
			resizable : true,
			width : 210,   //弹出框宽度
			height : 140,   //弹出框高度
			title : "温馨提示",  //弹出框标题
			position : "center",  //窗口显示的位置
		});
	});

</script>
	</head>

		<body style="font-family: '微软雅黑';">
		<div id="contentDiv" style="padding:4px; width:99%;">
			<div class="colnums-2-ab-b">
				<div class="toptil">
				    新增满减活动
					<!-- <a style="border:0px;text-align:left;padding-left: 0px;"><em id="title">新增</em>满减活动<em id="info" style="display:none">详情</em></a> -->
				</div>
					<div style="margin: 0 auto;">
						<table style="width: 90%;line-height: 50px;font-size: 14px;font-family: '微软雅黑';">
							<tr>
								<td class="tdL">满减活动名称：</td>
								<td class="tdR">
									<input id="rdeName" name="rdeName" value="${info.rdeName }"/>
									<input type="hidden" id="rdeId" name="rdeId" value="${info.rdeId }"/>
									<em class="rdeName" style="color: #f00;display: none;">满减活动名称不能为空</em>
								</td>
							</tr>
							<tr>
								<td class="tdL">开始时间：</td>
								<td class="tdR">
									<input type="text" id="begDate" name="begDate" onClick="WdatePicker({position:{left:220,top:141},dateFmt:'yyyy-MM-dd HH:mm:ss'})" 
								    	style="width: 180px;height: 24px; padding-left: 3px" readonly="readonly"  class="Wdate" value="${info.begTime }"/>
								    	<em class="begDate" style="color: #f00;display: none;">开始时间不能为空</em>
								</td>
							</tr>
							<tr>
								<td class="tdL">结束时间：</td>
								<td class="tdR">
									<input type="text" id="endDate" name="endDate" onClick="WdatePicker({position:{left:220,top:191},dateFmt:'yyyy-MM-dd HH:mm:ss'})" 
								    	style="width: 180px;height: 24px; padding-left: 3px" class="Wdate" value="${info.endTime }"/>
								    	<em class="endDate" style="color: #f00;display: none;">结束时间不能为空</em>
								</td>
							</tr>
							<tr>
								<td class="tdL">扣减金额：</td>
								<td class="tdR">
									<input id="cpsPrice" name="cpsPrice" value="${info.cpsPrice }" onkeyup="_verifyNum(this.id)"/>&nbsp;元
									<em class="regfacePrice" style="color: #f00;display: none;">扣减金额应为正整数</em>
									<em class="facePrice" style="color: #f00;display: none;">扣减金额不能为空</em>
								</td>
							</tr>
							<tr>
								<td class="tdL">使用条件：</td>
								<td class="tdR">
									<input id="useCtn" name="useCtn" value="${info.useCtn }" onkeyup="_verifyNum(this.id)"/>
									<em class="reguseCtn" style="color: #f00;display: none;">使用条件应为正整数</em>
									<em class="useCtn" style="color: #f00;display: none;">使用条件不能为空</em>
								</td>
							</tr>
							<tr>
								<td class="tdL">状态：</td>
								<td class="tdR">
									<select id="status" name="status" style="width: 180px;height: 24px;font-family: '微软雅黑';">
										<option value="1" <c:if test="${info.status eq '1' }">selected="selected"</c:if>>启用</option>
										<option value="0" <c:if test="${info.status eq '0' }">selected="selected"</c:if>>禁用</option>
									</select>
								</td>
							</tr>
							<tr><td class="tdL"></td><td style="text-align: left;">
									<button  type="button" onclick="_save()">保存</button>
									<button  type="button" onclick="window.history.go(-1);">返回</button>
								<!-- <div id="btnDiv" class="subDiv">
									<a onclick="_save()" class="subA" style="text-decoration:none;">提交</a>
								</div>
								<div id="backDiv" class="backDiv">
									<a onclick="javascript :history.back(-1)" class="subA" style="text-decoration:none;">返回</a>
								</div> -->
							</td></tr>
						</table>
					</div>
				</div>
				<div id="dialogDiv" style="text-align: center;padding-top:24px;display:none;">
					<em>满减活动信息不完整</em>
				</div>
		</div>
	</body>
	<script type="text/javascript">
	$(document).ready(function(){
			_reHeight("rightFrame","contentDiv");
	 });
</script>
</html>
